﻿<?php 
	/**    
	* FILE:          ProcessAjaxSearch.php    
	* LOCATION:      /web_root/actions/   
	* NOTES:  this file hanldes database queries from the ajax form in cieSearch.php     
	*     
	* ==============================================================================    
	* @version $Id: cieEdit.php,v 0.1 2008/08/10    
	* @copyright Copyright (c) none    
	* @author ChrisV    
	* ==== 
	*/
	$db = new mysqli('localhost', 'decentda_madm' ,'lala4566', 'decentda_HOCTILndsdevelopment');
	if(!$db) {
		// Show error if we cannot connect.
		echo 'ERROR: Could not connect to the database.';
	} else {
		// Is there a posted query string?
		if(isset($_POST['queryString'])) {
			$queryString = $db->real_escape_string($_POST['queryString']);
			// Is the string length greater than 0?
			if(strlen($queryString) >0) {
				$query = $db->query("SELECT id, first_name, last_name, phone FROM consumer WHERE first_name LIKE '$queryString%' ORDER BY last_name ASC LIMIT 50");
				if($query) {
					while ($result = $query ->fetch_object()) {
	        echo '<li>											<a href="http://www.ndsdatabase.org/hoctil/live/admin.php?action=cieedit&id='.$result->id.'">												 Consumer ID#: [ '												.$result->id.' ]  '												.$result->first_name.' '												.$result->last_name.' - ph. '												.$result->phone.											'</a>										</li>';
	      }
				} else {
					echo 'ERROR: There was a problem with the query.';
				}
			} else {
				// Dont do anything.
			} // There is a queryString.
		} else {
			echo 'There should be no direct access to this script!';
		}
	}
?>